package com.example.xm.service.impl;

import com.example.xm.entity.Fenlei;
import com.example.xm.entity.Geshou;
import com.example.xm.entity.Yinyue;
import com.example.xm.mapper.GeshouMapper;
import com.example.xm.mapper.YinyueMapper;
import com.example.xm.service.IGeshouService;
import com.example.xm.web.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GeshouServiceImpl implements IGeshouService {
    @Autowired
    private GeshouMapper geshouMapper;
@Autowired
    YinyueMapper yinyueMapper;
    @Override
    public PageInfo<Geshou>selectList(Geshou geshou) {
        PageHelper.startPage(geshou.getPage(),geshou.getSize());
        List<Geshou> geshous = geshouMapper.selectList(geshou);
        PageInfo<Geshou> adminPageInfo = new PageInfo<Geshou>(geshous);
        return adminPageInfo;
    }

    @Override
    public int add(Geshou geshou) {
        return geshouMapper.insertSelective(geshou);
    }

    @Override
    public int edit(Geshou geshou) {
        return geshouMapper.updateByPrimaryKeySelective(geshou);
    }

    @Override
    public void delete(int[] intArray) {
        geshouMapper.delete(intArray);
    }

    @Override
    public Geshou getData(Integer id) {
        Geshou geshou = geshouMapper.selectByPrimaryKey(id);
      List<Yinyue> list=  yinyueMapper.selectListByGeShouid(id);
      geshou.setList(list);
        return geshou;
    }

}
